home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SoundEditor.h
-
- Contains: Sound Editor class implementation
-
- Written by: Steve Smith, Andrey Dolgachev, and Troy Gaul
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- #ifndef _SOUNDEDITOR_
- #define _SOUNDEDITOR_
-
- // -- Compiler/Preprocessor Switches --
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- // -- Forward Declarations --
-
- struct Environment;
- class ODExtension;
- class ODFacet;
- class ODFocusSet;
- class ODFrame;
- class ODMenuBar;
- class ODPart;
- class ODShape;
- class ODStorageUnit;
- class ODStorageUnitView;
- class ODTypeList;
- class ODWindow;
- class CList;
- class CPlayer;
- class CRecorder;
- class CSounder;
- class som_SESettingsExtension;
- class SoundEditorSI;
- struct WindowProperties;
-
- #pragma import on
-
- //============================================================================
- // Constants
- //============================================================================
-
- // EButton enum:
- enum {
- kNoButton = -1,
- kRecordButton,
- kStopButton,
- kPauseButton,
- kPlayButton
- };
-
- // EButtonState enum:
- enum {
- kButtonStateNormal,
- kButtonStatePressed,
- kButtonStateOn,
- kButtonStateDim
- };
-
- //============================================================================
- // SoundEditor class
- //============================================================================
-
- class SoundEditor {
-
- //==================================
- // Overridden Public ODPart Methods
- //==================================
- public:
-
- SoundEditor();
- ~SoundEditor();
-
- // -- Initialization --
-
- void InitPart(Environment* ev, ODStorageUnit* storageUnit,
- ODPart* partWrapper);
- void InitPartFromStorage(Environment* ev, ODStorageUnit* storageUnit,
- ODPart* partWrapper);
-
- // -- Storage --
-
- void Release(Environment* ev);
- void ReleaseAll(Environment* ev);
- ODSize Purge(Environment* ev, ODSize size);
- void Externalize(Environment* ev);
- void ExternalizeKinds(Environment* ev, ODTypeList* kindset);
- void ChangeKind(Environment* ev, ODType kind);
- void CloneInto(Environment* ev, ODDraftKey key,
- ODStorageUnit* destinationSU,
- ODFrame* initiatingFrame);
- void WritePartInfo(Environment* ev, ODInfoType partInfo,
- ODStorageUnitView* storageUnitView);
- ODInfoType ReadPartInfo(Environment* ev, ODFrame* frame,
- ODStorageUnitView* storageUnitView);
- void ClonePartInfo(Environment *ev, ODDraftKey key, ODInfoType partInfo,
- ODStorageUnitView* storageUnitView,
- ODFrame* scopeFrame);
-
- // -- Layout --
-
- void DisplayFrameAdded(Environment* ev, ODFrame* frame);
- void DisplayFrameRemoved(Environment* ev, ODFrame* frame);
- void DisplayFrameClosed(Environment* ev, ODFrame* frame);
- void DisplayFrameConnected(Environment* ev, ODFrame* frame);
- void AttachSourceFrame(Environment* ev, ODFrame* frame,
- ODFrame* sourceFrame);
- void ViewTypeChanged(Environment* ev, ODFrame* frame);
- void FrameShapeChanged(Environment* ev, ODFrame* frame);
- ODID Open(Environment* ev, ODFrame* frame);
-
- // -- Imaging --
-
- void Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
- void GeometryChanged(Environment* ev, ODFacet* facet,
- ODBoolean clipShapeChanged,
- ODBoolean externalTransformChanged);
- void HighlightChanged(Environment* ev, ODFacet* facet);
- void FacetAdded(Environment* ev, ODFacet* facet);
- void FacetRemoved(Environment* ev, ODFacet* facet);
-
- // -- Activation --
-
- ODBoolean BeginRelinquishFocus(Environment* ev, ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame);
- void CommitRelinquishFocus(Environment* ev, ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame);
- void AbortRelinquishFocus(Environment* ev, ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame);
- void FocusAcquired(Environment* ev, ODTypeToken focus,
- ODFrame* ownerFrame);
- void FocusLost(Environment* ev, ODTypeToken focus,
- ODFrame* ownerFrame);
- void RelinquishAllFoci(Environment* ev, ODFrame* frame);
-
- // -- Event Handling --
-
- ODBoolean HandleEvent(Environment* ev, ODEventData* event,
- ODFrame* frame, ODFacet* facet,
- ODEventInfo* eventInfo);
- void AdjustMenus(Environment* ev, ODFrame* frame);
-
- ODBoolean HandleSoundEvent(Environment* ev, ODCommandID command);
-
- // -- Extension --
-
- ODBoolean HasExtension(Environment *ev, ODType extensionName);
- ODExtension* AcquireExtension(Environment *ev, ODType extensionName);
- ODBoolean ReleaseExtension(Environment *ev, ODExtension* extension);
-
- //===================================
- // Newly Introduced Internal Methods
- //===================================
-
- // -- Settings Dialog (these methods must be public) --
-
- void ShowSettingsDialog(Environment* ev, ODFrame* frame);
-
- // -- Sound Data Handling --
-
- ODBoolean SoundPlaying();
- ODBoolean SoundRecording();
- ODBoolean SoundPaused();
-
- OSType GetRecordingQuality();
- void SetRecordingQuality(OSType rQuality);
- ODBoolean GetSoundQuality(OSType* rQuality);
-
- ODULong GetCurrentTime();
- ODULong GetMaxTime();
- ODULong GetRecordedTime();
-
- //========================
- protected:
-
- // -- Initialization --
-
- void Initialize(Environment* ev);
- void BuildMenuBar(Environment* ev);
-
- // -- Storage --
-
- void CheckAndAddProperties(Environment* ev,
- ODStorageUnit* storageUnit);
- void CleanseContentProperty(Environment* ev,
- ODStorageUnit* storageUnit);
- void InternalizeStateInfo(Environment* ev,
- ODStorageUnit* storageUnit);
- void InternalizeAnnotation(Environment* ev,
- ODStorageUnit* storageUnit);
- void InternalizeContent(Environment* ev,
- ODStorageUnit* storageUnit);
- void ExternalizeStateInfo(Environment* ev,
- ODStorageUnit* storageUnit,
- ODDraftKey key, ODFrame* scopeFrame);
- void ExternalizeAnnotation(Environment* ev,
- ODStorageUnit* storageUnit,
- ODDraftKey key, ODFrame* scopeFrame);
- void ExternalizeContent(Environment* ev, ODStorageUnit* storageUnit,
- ODDraftKey key, ODFrame* scopeFrame,
- ODTypeToken kindToken);
- void SetDirty(Environment* ev);
-
- // -- Event Handling --
-
- ODBoolean HandleMenuEvent(Environment* ev, ODEventData* event,
- ODFrame* frame);
- ODBoolean HandleMouseEvent(Environment* ev, ODEventData* event,
- ODFacet* facet, ODEventInfo* eventInfo);
- ODBoolean HandleKeyboardEvent(Environment* ev, ODEventData* event,
- ODFrame* frame);
- ODBoolean DoMouseUp(Environment* ev, ODEventData* event, ODFacet* facet,
- ODEventInfo* eventInfo);
- void DoMouseDown(Environment* ev, ODEventData* event, ODFacet* facet,
- ODEventInfo* eventInfo);
-
- // -- Imaging --
-
- void DrawFrameView(Environment* ev, ODFacet* facet);
- void DrawIconView(Environment* ev, ODFacet* facet);
- void DrawThumbnailView(Environment* ev, ODFacet* facet);
- PicHandle GenerateThumbnail(Environment* ev, ODFrame* frame);
-
- // -- Activation --
-
- void PartActivated(Environment* ev, ODFrame* frame);
- ODBoolean ActivateFrame(Environment* ev, ODFrame* frame);
- void WindowActivating(Environment* ev, ODFrame* frame,
- ODBoolean activating);
-
- // -- Layout --
-
- ODWindow* AcquireFramesWindow(Environment* ev, ODFrame* frame);
- ODWindow* CreateWindow(Environment* ev, ODFrame* frame,
- ODType frameType,
- WindowProperties* windowProperties);
- void CleanupWindow(Environment* ev, ODFrame* frame);
- WindowProperties* GetDefaultWindowProperties(Environment* ev,
- ODFrame* frame, Rect* windowRect);
- WindowProperties* GetSavedWindowProperties(Environment* ev,
- ODFrame* frame);
- Rect CalcPartWindowSize(Environment* ev, ODFrame* sourceFrame);
- Rect CalcPartWindowPosition(Environment* ev, ODFrame* frame,
- Rect* partWindowBounds);
- void ZoomPartWindow(Environment* ev, ODFrame* frame, ODWindow* window,
- ODBoolean openingWindow);
- ODFacet* GetActiveFacetForFrame(Environment* ev, ODFrame* frame);
- ODShape* CalcNewUsedShape(Environment* ev, ODFrame* frame);
- void UpdateFrame(Environment* ev, ODFrame* frame, ODTypeToken view,
- ODShape* usedShape);
- void CleanupDisplayFrame(Environment* ev, ODFrame* frame,
- ODBoolean frameRemoved);
-
- // -- Sound Data Handling --
-
- void PlaySound(Environment* ev);
- void StopPlayingSound(Environment* ev);
- void PausePlayingSound(Environment* ev);
- void ResumePlayingSound(Environment* ev);
- ODBoolean SoundDonePlaying(Environment* ev);
-
- void RecordSound(Environment* ev);
- void StopRecordingSound(Environment* ev);
- void PauseRecordingSound(Environment* ev);
- void ResumeRecordingSound(Environment* ev);
- ODBoolean SoundDoneRecording(Environment* ev);
-
- void DrawMaxTime(Environment* ev, ODFacet* facet);
- void DrawCurrentTime(Environment* ev, ODFacet* facet,
- ODSShort oldTime, ODSShort curTime);
- void DrawProgressBar(Environment* ev, ODFacet* facet,
- ODSShort progress, ODSShort pixPatID);
- ODBoolean UpdateDisplay(Environment* ev, CSounder* sounder);
-
- void CopySound(Environment* ev, ODFrame* frame);
- void AnnotateClipboard(Environment* ev, ODFrame* frame);
- void PasteSound(Environment* ev, ODFrame* frame);
- void ClearSound(Environment* ev, ODFrame* frame);
- ODBoolean SoundOnClipboard(Environment* ev, ODFrame* frame);
-
- // -- Utilities
-
- PicHandle LoadControls(Environment* ev, ODFrame* frame);
- void DoDialogBox(Environment* ev, ODFrame* frame,
- ODSShort dialogID,
- ODUShort errorNumber = 0);
- ODFrame* FindFirstAvailableFrame(Environment* ev);
- void InvalidateFrameViewRect(Environment* ev, Rect& bounds);
-
- // -- Button Handling
-
- typedef ODSShort EButton;
- typedef ODSShort EButtonState;
-
- void DrawButton(Environment* ev, EButton, EButtonState);
- ODBoolean TrackButton(Environment* ev, EButton button, Point where,
- EButtonState initialState = kButtonStateNormal);
- void InvalidateButton(Environment* ev, EButton button);
-
- // -- More sound utilities
-
- ODBoolean IsPlayAvailable();
- ODBoolean IsPauseAvailable();
- ODBoolean IsStopAvailable();
- ODBoolean IsRecordAvailable();
-
- //========================
- private:
-
- ODPart* fSelf;
- ODSession* fSession;
-
- CList* fDisplayFrames;
- SoundEditorSI* fSemIntf;
- som_SESettingsExtension* fSettingsExtension;
-
- Handle fControls;
-
- CPlayer* fPlayer;
- CRecorder* fRecorder;
-
- ODTypeToken fPreferredKind;
-
- ODULong fMenuSavedResFile;
-
- OSType fRecordingQuality;
- ODULong fCurrentTime;
-
- ODULong fSecsRecorded;
- ODSLong fMaxMemory;
- ODSLong fMaxSeconds;
-
- ODBoolean fUnknownSound;
-
- ODBoolean fDirty;
- ODBoolean fReadOnlyStorage;
- };
-
- #pragma import off
-
- #endif